function insertNewTickerPost(jsonObject){
    var mainElement = document.getElementById("feedList").firstChild;
    var li = document.createElement("li");
    var feedDiv = document.createElement("div");
    var imageAnchor = document.createElement("a");
    var image = document.createElement("img");
    var innerDiv = document.createElement("div");
    var nameAnchor = document.createElement("a");
    var textDiv = document.createElement("div");
    var lineDiv = document.createElement("div");
    lineDiv.setAttribute("class", "feedseparatorsmall");

    li.appendChild(feedDiv);
                
    feedDiv.setAttribute("class", "feed");
    //onmouseover="tickerPopupMouseOver(${feed.relativeFilePath})" onmouseout="tickerPopupMouseOut()"
    feedDiv.setAttribute("onclick","tickerPopupMouseOver("+jsonObject.relativeFilePath+")");
    feedDiv.appendChild(imageAnchor);
    feedDiv.appendChild(innerDiv);
    imageAnchor.appendChild(image);
    imageAnchor.style.cssFloat = "left";
    imageAnchor.style.paddingRight = "10px";
    imageAnchor.setAttribute("href", "/norsemanserver/profile?username=" + jsonObject.username + "&typeOfBrowse=feed");
    imageAnchor.appendChild(image);

    image.setAttribute("alt", jsonObject.username);
    image.setAttribute("src", jsonObject.profilePicture);
    image.style.width = "30px";
    image.style.height = "30px";
                
                
    innerDiv.setAttribute("class", "feedright");
    innerDiv.appendChild(nameAnchor);
    innerDiv.appendChild(textDiv);
    nameAnchor.setAttribute("href", "/norsemanserver/profile?username=" + jsonObject.username + "&typeOfBrowse=feed");
    var newContent = document.createTextNode(jsonObject.username);
    var textDivContent = document.createTextNode(jsonObject.description);
    nameAnchor.appendChild(newContent);
    textDiv.appendChild(textDivContent);
    var parentDiv = mainElement.parentNode;
                
    parentDiv.insertBefore(li, mainElement);
    parentDiv.insertBefore(lineDiv, mainElement);
}
//isnerts media feed on ticker
function insertNewMediaTickerPost(jsonObject){
//    alert("called");
    var mainElement = document.getElementById("feedList").firstChild;
    var li = document.createElement("li");
    var feedDiv = document.createElement("div");
    var imageAnchor = document.createElement("a");
    var image = document.createElement("img");
    var innerDiv = document.createElement("div");
    var nameAnchor = document.createElement("a");
    var textDiv = document.createElement("div");
    var lineDiv = document.createElement("div");
    lineDiv.setAttribute("class", "feedseparatorsmall");

    li.appendChild(feedDiv);

    feedDiv.setAttribute("class", "mediaTickerfeed");
    //onmouseover="tickerPopupMouseOver(${feed.relativeFilePath})" onmouseout="tickerPopupMouseOut()"
    feedDiv.setAttribute("onclick","tickerMediaClick('"+jsonObject.relativeFilePath+"')");
    feedDiv.appendChild(imageAnchor);
    feedDiv.appendChild(innerDiv);
    imageAnchor.appendChild(image);
    imageAnchor.setAttribute("href", "#");
    imageAnchor.style.paddingRight = "10px";
    imageAnchor.style.cssFloat = "left";


    imageAnchor.appendChild(image);

    image.setAttribute("alt", jsonObject.username);
    image.setAttribute("src", jsonObject.profilePicture);
    image.style.width = "30px";
    image.style.height = "30px";


    innerDiv.setAttribute("class", "feedright");
    innerDiv.appendChild(nameAnchor);
    innerDiv.appendChild(textDiv);
    nameAnchor.setAttribute("href", "#");
    var newContent = document.createTextNode(jsonObject.username);
    var textDivContent = document.createTextNode(jsonObject.description);
    nameAnchor.appendChild(newContent);
    textDiv.appendChild(textDivContent);
    var parentDiv = mainElement.parentNode;

    parentDiv.insertBefore(li, mainElement);
    parentDiv.insertBefore(lineDiv, mainElement);
}


function insertForLiveLocationFeed(jsonObject){
    var mainElement = document.getElementById("feedcontent").firstChild;
    var feedDiv = document.createElement("div");
    var imageAnchor = document.createElement("a");
    var profilePicture = document.createElement("img");
    var innerDiv = document.createElement("div");
    var nameAnchor = document.createElement("a");
    var nameTextNode = document.createTextNode(jsonObject.username);
    var actionDiv = document.createElement("div");
    var postTextNode = document.createTextNode(jsonObject.description);
    var timeTextNode = document.createTextNode("At "+jsonObject.timestampString);
    var timeDiv = document.createElement("div");
    var lineDiv = document.createElement("div");
    lineDiv.setAttribute("class", "feedseparator");
                
    feedDiv.setAttribute("class", "feed");
    feedDiv.appendChild(imageAnchor);
    feedDiv.appendChild(innerDiv);
    imageAnchor.setAttribute("href", "/norsemanserver/profile?username=" + jsonObject.username + "&typeOfBrowse=feed");
    imageAnchor.style.paddingRight = "10px";
    imageAnchor.style.cssFloat = "left";
    imageAnchor.appendChild(profilePicture);
                
    profilePicture.setAttribute("src", jsonObject.profilePicture);
    profilePicture.setAttribute("alt", jsonObject.username);
    profilePicture.style.width = "50px";
    profilePicture.style.height = "50px";
                
    innerDiv.setAttribute("class", "feedright");
    innerDiv.appendChild(nameAnchor);
    innerDiv.appendChild(actionDiv);
    innerDiv.appendChild(timeDiv);
                
    actionDiv.appendChild(postTextNode);

    timeDiv.appendChild(timeTextNode);
                
    nameAnchor.setAttribute("href", "/norsemanserver/profile?username=" + jsonObject.username + "&typeOfBrowse=feed");
    nameAnchor.appendChild(nameTextNode);
    var parentDiv = mainElement.parentNode;
                
    parentDiv.insertBefore(feedDiv, mainElement);
    parentDiv.insertBefore(lineDiv, mainElement);
}
function insertForLiveMediaFeed(jsonObject){
//    alert("before");
    var mainElement = document.getElementById("feedcontent").firstChild;
    var feedDiv = document.createElement("div");
    var imageAnchor = document.createElement("a");
    var profilePicture = document.createElement("img");
    var innerDiv = document.createElement("div");
    var nameAnchor = document.createElement("a");
    var nameTextNode = document.createTextNode(jsonObject.username);
    var postTextNode = document.createTextNode(jsonObject.description);
    var timeTextNode = document.createTextNode("At "+jsonObject.timestampString);
    var imagePlacer = document.createElement("img");
    var timeDiv = document.createElement("div");
    var imageDiv = document.createElement("div");
    var lineDiv = document.createElement("div");
    lineDiv.setAttribute("class", "feedseparator");
   //for profile image
    feedDiv.setAttribute("class", "feed");
    feedDiv.appendChild(imageAnchor);
    feedDiv.appendChild(innerDiv);
    imageAnchor.setAttribute("href", "/norsemanserver/profile?username=" + jsonObject.username + "&typeOfBrowse=feed");
    imageAnchor.style.cssFloat = "left";
    imageAnchor.style.paddingRight = "10px";
    imageAnchor.appendChild(profilePicture);
   //profile picture
    profilePicture.setAttribute("src", jsonObject.profilePicture);
    profilePicture.setAttribute("alt", jsonObject.username);
    profilePicture.style.width = "50px";
    profilePicture.style.height = "50px";
   //div for live media
    innerDiv.setAttribute("class", "feedright");
    innerDiv.appendChild(nameAnchor);
    innerDiv.appendChild(postTextNode);
    innerDiv.appendChild(imageDiv);
    innerDiv.appendChild(timeDiv);
                
    imageDiv.appendChild(imagePlacer);
    imagePlacer.setAttribute("class", "feed_image");
    imagePlacer.setAttribute("src", jsonObject.relativeFilePath);
    imagePlacer.setAttribute("onclick", "tickerMediaClick('"+jsonObject.relativeFilePath+"')");
    imagePlacer.style.cursor = "pointer";

    timeDiv.appendChild(timeTextNode);
                
    nameAnchor.setAttribute("href", "/norsemanserver/profile?username=" + jsonObject.username + "&typeOfBrowse=feed");
    nameAnchor.appendChild(nameTextNode);
    var parentDiv = mainElement.parentNode;

    parentDiv.insertBefore(feedDiv, mainElement);
    parentDiv.insertBefore(lineDiv, mainElement);
//    alert("here");
}